package com.baozh.control;

import com.baozh.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/home")
public class FreeMarkerController {

    @RequestMapping("/index")
    public ModelAndView add(HttpServletRequest request, HttpServletResponse response){
        User user = new User();
        user.setUsername("sg");
        user.setPassword("1234");
        List<User> users  = new ArrayList<User>();
        users.add(user);

        ModelAndView mv = new ModelAndView();
        mv.setViewName("index");
        mv.addObject("users",users);
        return mv;
    }
}
